package org.an.proj.contacts.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import org.an.ku.util.SimpleTextWatcher;
import org.an.ku.view.fulllist.FullListAdapter;
import org.an.proj.contacts.R;
import org.an.proj.contacts.ui.contact.view.ContactItemBlockView;

/**
 * Created by an on 2016/10/23.<br/>
 * qq
 */

public class QqAdapter extends FullListAdapter<String> {
  public QqAdapter(Context context) {
    super(context);
  }

  @Override public View getView(ViewGroup parent, final int position, String info) {
    final ContactItemBlockView blockView = new ContactItemBlockView(mContext);
    blockView.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
    blockView.mBtnDel.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        // 将数据和view的处理直接放到adapter中处理
        getData().remove(position);
        // removeView不会移除divide所以还是 刷新吧
        //parent.removeView(blockView);
        notifyDataSetChanged();
      }
    });
    blockView.setData("QQ", mContext.getString(R.string.str_input_qq));
    blockView.mEdtInput.setText(info);
    blockView.mEdtInput.addTextChangedListener(new SimpleTextWatcher() {
      @Override public void afterTextChanged(String s) {
        getData().set(position, s);
      }
    });
    return blockView;
  }
}
